<?php

declare(strict_types=1);

namespace Core\Package\ElementPlus\FormCreate\FormItem;

/**
 * element-plus TagsInput
 */
class TagsInput extends FormItemAbstract
{
    protected string $_type = 'tags-input';


    /**
     * 获取值类型
     * @return string
     */
    public function valueType(): string
    {
        return self::VALUE_TYPE_ARRAY;
    }

    protected function defaultProps(): array
    {
        return [
            'limit' => 20,//默认条数
            'maxlength' => 250,//字数限制
        ];
    }


    public function __construct(string $field, string $title, array $value = [])
    {
        $this->_title = $title;
        $this->_field = $field;
        $this->_value = $value;
    }


    /**
     * 表单是否只读
     * @param int $limit
     * @return TagsInput
     */
    public function limit(int $limit): TagsInput
    {
        return $this->props('limit', $limit);
    }


    /**
     * 单个字数限制
     * @param int $maxlength
     * @return TagsInput
     */
    public function maxlength(int $maxlength): TagsInput
    {
        return $this->props('maxlength', $maxlength);
    }
}